<?php
    /**
    * Video Categories Management
    * @author: trungdt
    * @since: Oct 26, 2011
    * @version: 1.0
    * 
    * Change logs
    */

    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {   
        exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);

        // page title
        global $db;
        $temp = $db->selectObject("container", "internal = '".serialize($loc)."'");

        require_once(BASE."modules/formhelpermodule/formhelper.php");
        //$formhelper=new formhelper("linklistmodule","_manager_linklist_title","_manager_linklist",$loc);
        $formhelper=new formhelper("videomodule","Manage Video Categories","_manager_video_cat",$loc);
        $formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
        $formhelper->setGridOptions("height",800);
        $formhelper->setGridOptions("idField","id");
        $formhelper->setGridOptions("pagination",1);
        $formhelper->setGridOptions("pageNumber","1");
        $formhelper->setGridOptions("pageSize","20");
        $formhelper->setGridOptions("rownumbers","true");
        $formhelper->setGridOptions("nowrap","false");
        $formhelper->setGridOptions("singleSelect","true");
        $formhelper->setGridOptions("autoRowHeight","true");

        $formhelper->setGridID("manage_link");
        $js=URL_FULL."modules/videomodule/js/Cat_Manage.js";
        $formhelper->addJS($js);

        $css=URL_FULL."modules/videomodule/js/Cat_Manage.css";
        $formhelper->addCss($css);

        $formhelper->setColumnType(1);
        $formhelper->addColumn(array("field"=>"title","title"=>"Name",'width'=>230));
        $formhelper->addColumn(array("field"=>"seo_name","title"=>"Seo Name",'width'=>120));
        $formhelper->addColumn(array("field"=>"search_des","title"=>"Search Description",'width'=>180));
        
        $link_param="/index.php?module=videomodule&action=video_cat_getjson&src={$loc->src}&ajax_action=1";
        
        $formhelper->setURLDataStream($link_param);
        $formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
        $toolbar_template=new template("videomodule","_CatManage_ToolbarHTML",$loc);
        $toolbar_template->register_permissions(array('administrate',"configure"),$loc);
        $toolbar_html=$toolbar_template->render();
        $formhelper->addToolbarHTML($toolbar_html);
        $formhelper->setPreInitJSCall("form_syslog_preinit");
        $formhelper->register_permissions(array('administrate',"configure"),$loc);
        $formhelper->output();
        
        exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC","top_loginmodule_".LANG);
        exponent_sessions_set("AB_THEME_TOP_CONTAINER_TYPE","textmodule");
    }
    else
    {
        echo exponent_http_error(403);
    }
?>